﻿Imports System.IO
Imports System.Xml
Imports ModifyOutlook


Module ParsingUsingXmlDocument

    Sub Main()
        'Load the xml user control file
        Try
            Dim m_xmld As XmlDocument
            Dim m_nodelist As XmlNodeList
            Dim m_node As XmlNode
            Dim o As New ModifyOutlook.ModifyOutLook

            'Create the XML Document
            m_xmld = New XmlDocument()
            'Load the Xml file
            m_xmld.Load("user.xml")
            'Get the list of name nodes 
            m_nodelist = m_xmld.SelectNodes("/user_control/vet")
            'First we have to delete all previous appointments

            'Loop through the nodes
            For Each m_node In m_nodelist
                Dim cs_id = m_node.Item("cs_id").InnerXml
                'Dim cs_id = m_node.ChildNodes.Item(0).InnerText
                Dim username = m_node.Item("username").InnerXml
                Dim pwd = m_node.Item("pwd").InnerXml
                Dim domain = m_node.Item("domain").InnerXml
                Dim server = m_node.Item("server").InnerXml
                Dim appt_file = m_node.Item("appt_file").InnerXml
                Dim subject_text = m_node.Item("subject_text").InnerXml
                Dim reminder = m_node.Item("reminder").InnerXml

                o.cs_id = cs_id
                o.username = username
                o.pwd = pwd
                o.domain = domain
                o.appt_file = appt_file
                o.server = server
                o.subject_text = subject_text
                o.reminder = reminder
                
                Console.WriteLine("Deleting OutlookAppts....")
                o.FindAndDeleteOutlookAppt()

                Console.WriteLine("Call BuildOutlookAppts for CS ID: " & cs_id)
                o.BuildOutlookAppts()
            Next
        Catch errorVariable As Exception
            'Error trapping
            Console.Write(errorVariable.ToString())
        End Try
        
    End Sub      
        
End Module





